package com.ozonetel.model;

import java.io.Serializable;
import net.sf.json.JSONObject;

/**
 * @author <a href="mailto:sudhakargupta.s@gmail.com">SudhakarGupta</a>
 */
public class PhoneNumberInfo implements Serializable {

    private String inputNumber;
    private String location;
    private String operator;
    private String type;        //  FIXED, MOBILE
    private String stdCode;
    private boolean valid;
    private String callType;
    private String region;
    private boolean validForRegion;
    private JSONObject formats;

    /**
     * default constructor
     */
    public PhoneNumberInfo() {
    }

    /**
     * @param inputNumber
     * @param location
     * @param operator
     * @param type
     * @param stdCode
     */
    public PhoneNumberInfo(String inputNumber, String location,
            String operator, String type, String stdCode,
            boolean valid, JSONObject formats) {
        this.inputNumber = inputNumber;
        this.location = location;
        this.operator = operator;
        this.type = type;
        this.stdCode = stdCode;
        this.valid = valid;
        this.formats = formats;
    }

    /**
     * @return the inputNumber
     */
    public String getInputNumber() {
        return inputNumber;
    }

    /**
     * @param inputNumber the inputNumber to set
     */
    public void setInputNumber(String inputNumber) {
        this.inputNumber = inputNumber;
    }

    /**
     * @return the location
     */
    public String getLocation() {
        return location;
    }

    /**
     * @param location the location to set
     */
    public void setLocation(String location) {
        this.location = location;
    }

    /**
     * @return the operator
     */
    public String getOperator() {
        return operator;
    }

    /**
     * @param operator the operator to set
     */
    public void setOperator(String operator) {
        this.operator = operator;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @return the stdCode
     */
    public String getStdCode() {
        return stdCode;
    }

    /**
     * @param stdCode the type to set
     */
    public void setStdCode(String stdCode) {
        this.stdCode = stdCode;
    }

    /**
     * @return the valid or not
     */
    public boolean isValid() {
        return valid;
    }

    /**
     * @param valid the type to set
     */
    public void setValid(boolean valid) {
        this.valid = valid;
    }

    /**
     * @return the callType
     */
    public String getCallType() {
        return callType;
    }

    /**
     * @param callType the callType to set
     */
    public void setCallType(String callType) {
        this.callType = callType;
    }

    /**
     * @return the region
     */
    public String getRegion() {
        return region;
    }

    /**
     * @param region the region to set
     */
    public void setRegion(String region) {
        this.region = region;
    }

    /**
     * @return the validForRegion
     */
    public boolean isValidForRegion() {
        return validForRegion;
    }

    /**
     * @param validForRegion the validForRegion to set
     */
    public void setValidForRegion(boolean validForRegion) {
        this.validForRegion = validForRegion;
    }

    /**
     * @return the formats map
     */
    public JSONObject getFormats() {
        return formats;
    }

    /**
     * @param formats the type to set
     */
    public void setFormats(JSONObject formats) {
        this.formats = formats;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("{");
        sb.append("'inputNumber':'").append(inputNumber).append("',");
        sb.append("'location':'").append(location).append("',");
        sb.append("'operator':'").append(operator).append("',");
        sb.append("'type':'").append(type).append("',");
        sb.append("'stdCode':'").append(stdCode).append("',");
        sb.append("'formats':").append(formats).append("");
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PhoneNumberInfo phoneNumberInfo = (PhoneNumberInfo) obj;
        if ((this.inputNumber == null) ? (phoneNumberInfo.inputNumber != null) : !this.inputNumber.equals(phoneNumberInfo.inputNumber)) {
            return false;
        }
        if ((this.location == null) ? (phoneNumberInfo.location != null) : !this.location.equals(phoneNumberInfo.location)) {
            return false;
        }
        if ((this.operator == null) ? (phoneNumberInfo.operator != null) : !this.operator.equals(phoneNumberInfo.operator)) {
            return false;
        }
        if ((this.type == null) ? (phoneNumberInfo.type != null) : !this.type.equals(phoneNumberInfo.type)) {
            return false;
        }
        if ((this.stdCode == null) ? (phoneNumberInfo.stdCode != null) : !this.stdCode.equals(phoneNumberInfo.stdCode)) {
            return false;
        }
        if (this.valid != phoneNumberInfo.valid) {
            return false;
        }
        if ((this.formats == null) ? (phoneNumberInfo.formats != null) : !this.formats.equals(phoneNumberInfo.formats)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.inputNumber != null ? this.inputNumber.hashCode() : 0);
        hash = 59 * hash + (this.location != null ? this.location.hashCode() : 0);
        hash = 59 * hash + (this.operator != null ? this.operator.hashCode() : 0);
        hash = 59 * hash + (this.type != null ? this.type.hashCode() : 0);
        hash = 59 * hash + (this.stdCode != null ? this.stdCode.hashCode() : 0);
        hash = 59 * hash + (this.valid ? 1 : 0);
        hash = 59 * hash + (this.formats != null ? this.formats.hashCode() : 0);
        return hash;
    }
}